<template>
  <div class="mark-box">
    <div class="mark-item" v-for="(item, index) in markList" :key="index"
         @click="openTarget(item.targetUrl)">
      <img :src="item.icon" class="item-icon">
      <!-- 标题 -->
      <div class="item-info">
        <p class="item-title" :title='item.title'>{{item.title}}</p>
        <p class="item-explain" :title='item.explain'>{{item.explain}}</p>
      </div>
    </div>
    <div class="mark-empty" v-if="markList.length < 1">
      暂无书签
    </div>
  </div>
</template>

<script setup>
defineProps({
  markList: {
    type: Array,
    required: true
  }
})

// 打开目标网站
const openTarget = (url) => {
  window.open(url);
}

</script>

<style lang="scss" scoped>
.mark-box {
  height: 90%;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  .mark-item {
    width: 46%;
    cursor: pointer;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 10px;
    margin: 8px 20px;
    height: 110px;
    &:hover {
      background: rgba(255, 255, 255, 0.8);
      box-shadow: 8px 8px 8px rgba(0, 0, 0, 0.2);
    }
    .item-icon {
      width: 15%;
    }
    .item-info {
      width: 85%;
      padding: 0 20px;
      font-size: 14px;
      .item-title {
        font-weight: 700;
        margin-bottom: 10px;
        color: #2f3e4c;
        font-size: 18px;
      }
      .item-explain {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
  }
  .mark-empty {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
  }
}
</style>
